package com.abs.orm;

import java.lang.reflect.Modifier;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

import com.abs.orm.convert.util.ConvertUtil;
import com.abs.orm.db.dao.DaoForMySQL;
import com.abs.orm.db.jdbc.ConnectionManager;
import com.abs.orm.util.FileUtil;
import com.ads.orm.model.j.JField;
import com.ads.orm.model.j.JMethod;

public class MainApp {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		MainApp.createTable();

	}

	public static void test() {
		Modifier m;
		JField a = new JField("private", "String", "name");
		String s = ConvertUtil.convert2Attribute(a).toString();
		System.out.print(s);
		s = ConvertUtil.convert2Get(new JMethod(a)).toString();
		System.out.print(s);
		s = ConvertUtil.convert2Set(new JMethod(a)).toString();
		System.out.print(s);
	}

	public static void createTable() {
		try {
			Statement stmt = ConnectionManager.getConnection().createStatement();
			for (int i = 0; i < 10; i++) {
				stmt.execute("DROP TABLE IF EXISTS `app_user" + i + "`");
				stmt.execute("create table app_user" + i + "( numid int primary key)");
			}

		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public static void createFile() {
		List list = DaoForMySQL.getInstance().getTables();
		// new DaoImplForMySQL().getFields((Table) list.get(0));
		String temp = "''''''''32423'';理朝阳、\r\nh";
		FileUtil.create("D:\\css.txt", list.toString(), "UTF-8");
		FileUtil.read("D:\\css.txt", "UTF-8");
	}
}
